package com.gitee.wsl.mathematics.algebraic.number

import com.gitee.wsl.mathematics.algebraic.Algebra

/**
 * Scale by scalar operations
 */
 interface ScaleOperations<T> : Algebra<T> {
    /**
     * Scaling an element by a scalar.
     *
     * @param a the multiplier.
     * @param value the multiplicand.
     * @return the produce.
     */
     fun scale(a: T, value: Double): T

    /**
     * Multiplication of this element by a scalar.
     *
     * @receiver the multiplier.
     * @param k the multiplicand.
     * @return the product.
     */
     operator fun T.times(k: Number): T = scale(this, k.toDouble())

    /**
     * Division of this element by scalar.
     *
     * @receiver the dividend.
     * @param k the divisor.
     * @return the quotient.
     */
     operator fun T.div(k: Number): T = scale(this, 1.0 / k.toDouble())

    /**
     * Multiplication of this number by element.
     *
     * @receiver the multiplier.
     * @param arg the multiplicand.
     * @return the product.
     */
     operator fun Number.times(arg: T): T = arg * this
}